// stores/phone.js
import { defineStore } from 'pinia';
import { ref, computed } from 'vue';

export const usePhoneStore = defineStore('phone', () => {
  const phoneNumber = ref(localStorage.getItem('phoneNumber') || '');  // 从 localStorage 中获取手机号
  // const name = ref('用户名');

  // 设置手机号的函数
  const setPhone = (phone) => {
    console.log('setPhone', phone);
    phoneNumber.value = phone;
    localStorage.setItem('phoneNumber', phone);  // 保存到 localStorage
  }

  return {
    phoneNumber,name,
    setPhone,
  };
}, {
  persist: true  // 启用持久化
});
